﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace WCC.QuadTree
{
    public class Tree : INode
    {
        /// <summary>
        /// 空间边界
        /// </summary>
        public Bounds bound { get; set; }
        /// <summary>
        /// 根节点
        /// </summary>
        public Node root;
        /// <summary>
        /// 最大节点深度
        /// </summary>
        public int maxDepth { get; }
        /// <summary>
        /// 最多子节点数量
        /// </summary>
        public int maxChildCount { get; }
        public float viewRatio = 1;

        public Tree(Bounds bound)
        {
            this.bound = bound;
            this.maxDepth = 5;
            this.maxChildCount = 4;
            //给场景创建一个0级深度的树节点
            root = new Node(bound, 0, this);
        }

        public void InsertObjData(ObjData obj)
        {
            root.InsertObjData(obj);
        }

        public void Inside(Camera camera)
        {
            root.Inside(camera);
        }

        public void Outside(Camera camera)
        {
            root.Outside(camera);
        }

        public void DrawBound()
        {
            root.DrawBound();
        }
    }
}